#ifndef _DSWVIDEO_CODEC_H
#define _DSWVIDEO_CODEC_H
#include <libbase/dswmemlistbase.h>
#include <libdswmemory/dswmemory.h>
#include <libdswav/dswosd.h>

class CDswvideo_codec : public CDswmemlistbase
{
public:
	CDswvideo_codec(LPST_ENV_T pEnv, int nMemSize);
	virtual ~CDswvideo_codec();
private:
	void InitList();
	void UnInitList();

	void StartStream();
	void StopStream();

	static void* cbEncThreadFunc(void* pParam){((CDswvideo_codec*)pParam)->EncThreadFunc();return NULL;};
	void EncThreadFunc();

	bool GetVideoFrame(LPST_VIDEO_FRAME_T pFrame);

	void StartCapThread();
	void StopCapThread();
	static void* cbCapThreadFunc(void* pParam){((CDswvideo_codec*)pParam)->CapThreadFunc();return NULL;};
	void CapThreadFunc();
	LPST_ALARM_NODE_T GetCapNode(LPLIST_ST_ALARM_NODE_T pList);
	void PutCapNode(LPST_ALARM_NODE_T pNode, LPLIST_ST_ALARM_NODE_T pList);
protected:
	virtual bool DumpFrame(void* pSrc, void* pDest);
	virtual int OnMessage(EN_MSG_TYPE nMsgType, void * pParam);
private:
	pthread_t m_nEncThread, m_nCapThread;
	CDswmemory* m_pMemory;
	CDswosd* m_pOsds[MAX_CHANNEL_LOCAL];

	void *m_groupfd;
	void* m_main_bindfd[MAX_CHANNEL_LOCAL];
	void* m_sub_bindfd[MAX_CHANNEL_LOCAL];
	void* m_capture_object[MAX_CHANNEL_LOCAL];
	void* m_main_enc_object[MAX_CHANNEL_LOCAL];
	void* m_sub_enc_object[MAX_CHANNEL_LOCAL];

	ST_VIDEO_PARAM m_nRuntimeParam;

	LIST_ST_ALARM_NODE_T m_nCapNodeList, m_nCapNodeList_UnUsed;
	pthread_mutex_t m_nCapNodeList_lock;

	gm_palette_table_t m_nPalette;
};

#endif

